<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="林镭特">

    <title></title>
    <style>
        .box {
        width: 590px;
        height: 470px;
        margin: 100px auto;
        position: relative;
        cursor: pointer;
      }
      ul {
        margin: 0;
        list-style: none;
        padding: 0;
      }
      .img-box {
        position: absolute;
        top: 0;
        left: 0;
        /* display: none; */
      }

      .img-box li {
        display: none;
        transition: all .5s;
        
      }
      .img-box li img{
          width: 590px;
          height: 470px;
          transition: all .5s;
      }
      .img-box li.active {
        display: block;
       
        opacity: 1;
        
      }
      .indicator-box {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 50px;
        display: flex;
        justify-content: center;
       
      }
      .indicator-box li {
        width: 10px;
        height: 10px;
        text-align: center;
        border-radius: 50%;
        background-color: rgba(255, 255, 255, 0.4);
        margin: 5px;
      }
      .indicator-box li.current {
        background-color: #fff;
      }
      .btn {
        width: 30px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        background-color: rgba(255, 255, 255, 0.4);
        position: absolute;
        font-size: 26px;
        top: calc(50% - 15px);
      }
      .next-btn {
        right: 0;
        border-top-left-radius: 18px;
    border-bottom-left-radius: 18px;
      }
      .prev-btn{
        border-top-right-radius: 18px;
    border-bottom-right-radius: 18px;
      }
      
    </style>
</head>
<body>
    <div class="box">
        <ul class="img-box">
          <li class="active"><img src="img/jd1.jpg" alt="" /></li>
          <li><img src="img/jd2.jpg" alt="" /></li>
          <li><img src="img/jd3.jpg" alt="" /></li>
          <li><img src="img/jd4.jpg" alt="" /></li>
        </ul>
  
        <ul class="indicator-box">
          <li class="current"></li>
          <li></li>
          <li></li>
          <li></li>
        </ul>
        <div class="btn-box">
          <span class="btn prev-btn">&lt;</span>
          <span class="btn next-btn">&gt;</span>
        </div>
      </div>
    <script src="jQuery.js"></script>
<script>
   
    var index = 0;
    var timer = setInterval(next, 2000);
    var lis = $('.img-box li');

    $('.next-btn').click(next);
    $('.prev-btn').click(prev);

    function prev() {
        index = index === 0 ? lis.length - 1 : index - 1;
        change();
    }

    function next() {
        index = index === lis.length - 1 ? 0 : index + 1;
        // $('img').css('','')
        change();
    }

    function change() {
        lis.eq(index)
        .addClass('active')
        .siblings()
        .removeClass('active');
        $('.indicator-box li')
        .eq(index)
        .addClass('current')
        .siblings()
        .removeClass('current');
    }

    $('.box').hover(function () {
        clearInterval(timer);
    }, function () {
        timer = setInterval(next, 2000)
    })


</script>
</body>
</html>